package com.lxx.consumer.controller;

import com.lxx.consumer.pojo.User;
import com.lxx.consumer.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.*;

/**
 * @author liuxing
 * @create 2022-08-27 1:17
 */
@RestController
@RequestMapping("/consumer")
@RefreshScope
public class UserController {

    @Value("${xxx}")
    private String xxx;

    @Autowired
    private UserService userService;

    @ResponseBody
    @GetMapping("/user/{id}")
    public User getUserById(@PathVariable("id") Long id){
        User user = userService.getUserById(id);
        user.setName(xxx);
        return user;
    }
}
